package pcgen;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class ChainedComparator<T> implements java.util.Comparator<T>
{
    public ChainedComparator(Comparator<T>... simpleComparators) 
    {
        _internalComparators = Arrays.asList(simpleComparators);
    }
    
    public int compare(T o1, T o2) 
    {
        for (Comparator<T> comparator : _internalComparators) 
        {
            int result = comparator.compare(o1, o2);
            if (result != 0)
                return result;
        }
        
        return 0;
    }
    
    private List<Comparator<T>> _internalComparators; 
}